package com.qingke.beSuper2;

import com.qingke.beSuper2.command.CommandFactory;
import com.qingke.beSuper2.command.Command;
import com.qingke.beSuper2.command.SystemCommandFactory;
import com.qingke.beSuper2.pojo.Player;
import com.qingke.beSuper2.utils.QingkeConsole;

public class BeSuperApplication {

	private Player playerProfile;
	
	private static BeSuperApplication instance;
	
	private BeSuperApplication() {
	}
	
	public static synchronized BeSuperApplication getInstance() {
		if (instance == null) {
			instance = new BeSuperApplication();
		}
		return instance;
	}
	
	public static void main(String[] args) {
		
		QingkeConsole.println("Welcome to play this game, you can use the \"HELP\" for command usage.");
		
		while(true) {
			String cmd = QingkeConsole.askUserInput("cmd > ");
			
			Player player = BeSuperApplication.getInstance().getPlayerProfile();
			CommandFactory commandFactory = 
					CommandFactory.buildFactory(player);
			Command command = commandFactory.buildCommand(cmd);
			if (command != null) {
				command.execute();
			}
		}
		
	}

	private Player getPlayerProfile() {
		return playerProfile;
	}
	
}
